var fs = require("fs");
var a = fs.readFileSync('input2.json');
let read = JSON.parse(a)



read.forEach((ARR,j) => {
    let b = []
    for (let index = 0; index < ARR.length; index++) {
        if (ARR[index].hasOwnProperty("children")) {
            b.push(ARR[index])
        }
        
    }
    console.log(b.length)
    read[j] = b
});

    



fs.writeFile('input3.json', JSON.stringify(read), function (err) {
    if (err) {
        return console.error(err);
    }
    console.log("数据写入成功！");
    console.log("--------我是分割线-------------")
    console.log("读取写入的数据！");

});
